<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>圆</title>
	</head>
	<body>
		<div >	
		<p><strong>半径：</strong></p>
		<input type="text" id="r" />
		<br />
		<br />
		<input id="btn2" type="button" value="周长" onclick="zc()" />
	    <input id="btn1" type="button" value="面积" onclick="mj()" />
		<p id="outcome"></p>
		<script>
			function zc(){
				var r=document.getElementById("r");
				var outcome=document.getElementById("outcome");
				var result=Number(r.value)*2*3.14;
				if(result==0){
					alert("请输入圆的半径");
				}else if(isNaN(result)){
					alert("请输入数字");
				}else{
					outcome.innerHTML=result;
				}
			}
			function mj(){
				var r=document.getElementById("r");
				var outcome=document.getElementById("outcome");
				var result=Number(r.value)*Number(r.value)*3.14;
				if(result==0){
					alert("请输入圆的半径");
				}else if(isNaN(result)){
					alert("请输入数字");
				}else{
					outcome.innerHTML=result;
				}
			
			}
		</script>
		</div>	
	</body>
</html>
